<?php

$params = require(__DIR__ . '/params.php');
$config = [
    'id' => 'basic',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'aliases'=>[
        '@utils' => '@app/utils'
    ],
    'defaultRoute'=>'search',
    'components' => [
        'request' => [
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => '4ljklo',
        ],
//        'elasticsearch' => [
//            'class' => 'yii\elasticsearch\Connection',
//            'nodes' => [
//                ['http_address' => '127.0.0.1:9200'],
//                // configure more hosts if you have a cluster
//            ],
//        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        'user' => [
            'identityClass' => 'app\models\User',
            'enableAutoLogin' => true,
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'useFileTransport' => false,
            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'smtp.163.com',
                'username' => 'gaodu13@163.com',
                'password' => '593021022',
                'port' => '465',
                'encryption' => 'ssl',
            ],
            'messageConfig'=>[
                'charset'   =>  'UTF-8',
                'from'  =>[
                    'gaodu13@163.com'=>'快捷开发'
                ]
            ],
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'db' => require(__DIR__ . '/db.php'),
        'qtk'=> [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=testdb.quan007.com:3307;dbname=qingtaoke',
            'username' => 'qingtaoke',
            'password' => 'qAY6v4Xu7PsmQ2somfVY',
            'charset' => 'utf8',
            'tablePrefix' => 'qtk_',   //加入前缀名称qtk_
        ],
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
//            'suffix' => '.html',
            'rules' => [
                'site/jump/<url:\w+>.html' => 'site/jump',
                'search/index/p<page:\d+>/per<per-page:\d+>.html' => 'search/index',
                'search/index/<cat:\d+>.html' => 'search/index',

                'search/list/<key_word:\w+>/p<page:\d+>/per<per-page:\d+>.html' => 'search/list',
                'search/list/<key_word:\w+>' => 'search/list',

                '<controller>/<action>.html' => '<controller>/<action>',
            ],
        ],
    ],
    'params' => $params,
];

//if (YII_ENV_DEV) {
//    // configuration adjustments for 'dev' environment
//    $config['bootstrap'][] = 'debug';
//    $config['modules']['debug'] = [
//        'class' => 'yii\debug\Module',
////        'allowedIPs' => [ '*']
//    ];

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
//        'allowedIPs' => [ '*']
    ];
//}

return $config;
